import axios from "@/utils/request";
import { IBanner, IPlayList, IPlayListComment, ISinger, ISong, IUser } from "./types";
// 登录状态
export async function Login({ username, password }: { username: string; password: string }) {
    const { success } = await axios.post<{ success: string }>('admin/login/status', {
		name:username,
        password:password,
	});
	return success;
}
//获取所有歌手
export async function getAllSinger(query: string) {
    const { data } = await axios.get<{ data: ISinger[] }>('/singer', {
		query
	});
	return data;
}
//获取所有歌曲
export async function getSongs(query: string) {
    const { data } = await axios.get<{ data: ISong[] }>('/song/all', {
		query
	});
	return data;
}
//添加歌曲
export async function addSongs(params: any) {
    const { data } = await axios.posts<{ data: ISong[] }>('/song/add', {
		...params
	});
	return data;
}
//删除歌曲
export async function delSongs(id: number) {
    const { data } = await axios.get<{ data: ISong[] }>('/song/delete', {
		id
	});
	return data;
}
//修改歌曲所有歌曲
export async function updateSongs(params: any) {
    const { data } = await axios.posts<{ data: ISong[] }>('/song/update', {
		...params
	});
	return data;
}
//获取所有歌单
export async function getAllPlayList(query: string) {
    const { data } = await axios.get<{ data: IPlayList[] }>('/playList', {
		query
	});
	return data;
}
//获取所有用户
export async function getAllUser(query: string) {
    const { data } = await axios.get<{ data: IUser[] }>('/user/all', {
		query
	});
	return data;
}
//修改用户信息
export async function updateUser(params: any) {
    const { data } = await axios.put<{ data: IUser[] }>('/user/update', {
		...params
	});
	return data;
}
//获取所有歌单评论
export async function getAllCommentPlayList(params: any) {
    const { data } = await axios.get<{ data: IPlayListComment[] }>('/playListAllComment/detail', {
		...params
	});
	return data;
}
//获取所有歌曲评论
export async function getAllCommentSong() {
    const { data } = await axios.get<{ data: IPlayListComment[] }>('/playListComment/detail', {
	});
	return data;
}
//获取某个用户信息
export async function getUserById(id:number) {
    const { data } = await axios.get<{ data: IUser }>('/user/one', {
		id:id,
	});
	return data;
}
//获取轮播数据
export async function getBanners() {
    const { data } = await axios.get<{ data: IBanner[] }>('/banner', {
	});
	return data;
}
//添加轮播数据
export async function addBanner(file:any) {
    const { data } = await axios.post<{ data: IBanner[] }>('/banner/add', {
		file
	});
	return data;
}
//修改轮播数据
export async function updateBanner(params:any) {
    const { data } = await axios.post<{ data: IBanner[] }>('/banner/update', {
		...params
	});
	return data;
}
//删除轮播数据
export async function delBanner(id:number) {
    const { data } = await axios.post<{ data: IBanner[] }>('/banner/delete', {
		id
	});
	return data;
}
//文件上传
export async function fileUpload(params:any) {
    const { data } = await axios.post<{ data: any }>('/mv/upload', {
		...params   // type:文件夹名称   file:文件  
	});
	return data;
}
//获取MV数据
export async function getMvs(query:any) {
    const { data } = await axios.get<{ data: IBanner[] }>('/mv/select', {
		query
	});
	return data;
}
//添加MV数据
export async function addMv(params:any) {
    const { data } = await axios.posts<{ data: IBanner[] }>('/mv/add', {
		...params
	});
	return data;
}
//修改MV数据
export async function updateMv(params:any) {
    const { data } = await axios.posts<{ data: IBanner[] }>('/mv/update', {
		...params
	});
	return data;
}
//删除MV数据
export async function delMv(mvId:number) {
    const { data } = await axios.delete<{ data: IBanner[] }>('/mv/delete', {
		mvId
	});
	return data;
}
//获取音乐资讯
export async function getMusicInfo(query: string) {
	const { data } = await axios.get<{ data: any }>('/information/select', {
		query
	});
	return data;
	}
//添加音乐资讯
export async function addMusicInfo(obj: any) {
	const { data } = await axios.posts<{ data: any }>('/information/add', {
		...obj
	});
	return data;
}
//修改音乐资讯
export async function updateMusicInfo(obj: any) {
	const { data } = await axios.posts<{ data: any }>('/information/update', {
		...obj
	});
return data;
}
//删除音乐资讯
export async function delMusicInfo(InformationId: number) {
	const { data } = await axios.delete<{ data: any }>('/information/delete', {
		InformationId
	});
return data;
}
//删除歌单评论
export async function delComment(params: any) {
	const { data } = await axios.delete<{ data: any }>('/comment/delete', {
		...params
	});
return data;
}
//删除用户
export async function delUser(id:number) {
    const { success } = await axios.delete<{ success: string }>('user/deleteone', {
		userId:id
	});
	return success;
}
//删除用户们
export async function delUsers(ids:number[]) {
    const { success } = await axios.delete<{ success: string }>('user/deleteall', {
		userIds:ids,
	});
	return success;
}
//更新用户信息
export async function updateUserMsg(params: any) {
	const { success } = await axios.put<{ success:string }>('user/update', {
		...params
	});
	return success;
}
//添加用户信息
export async function addUserMsg(params: any) {
	const { success } = await axios.posts<{ success:string }>('user/add', {
		...params
	});
	return success;
}
//歌单的
//删除歌单
export async function delPlayList(id:number) {
    const { success } = await axios.delete<{ success: string }>('deleteplaylist', {
		id:id
	});
	return success;
}
//删除歌单们
export async function delPlayLists(ids:number[]) {
    const { success } = await axios.delete<{ success: string }>('deleteallplay', {
		playIds:ids,
	});
	return success;
}
//更新歌单信息
export async function updatePlayList(params: ang) {
	const { success } = await axios.put<{ success:string }>('updatePlayList', {
		...params
	});
	return success;
}
//添加歌单
export async function addPlayList({ title, introduction, style }:
	{ title: string,introduction:string, style:string }) {
const { success } = await axios.posts<{ success:string }>('addPlayList', {
introduction:introduction, 
title:title,
style:style,
});
return success;
}
//歌手
//删除歌手
export async function delSinger(id:number) {
    const { success } = await axios.delete<{ success: string }>('deletesinger', {
		id:id
	});
	return success;
}
//删除歌手们
export async function delSingers(ids:number[]) {
    const { success } = await axios.delete<{ success: string }>('deleteallsinger', {
		singerIds:ids,
	});
	return success;
}
//更新歌手信息
export async function updateSinger(params: any) {
    const { data } = await axios.put<{ data: ISinger[] }>('/updateSinger', {
		...params
	});
	return data;
}
//添加歌手
export async function addSinger({ name, sex, location, introduction, birth, areaType}:
	{ name: string; sex: any, location:string, introduction:string, birth:Date, areaType:number}) {
const { success } = await axios.posts<{ success:string }>('addSinger', {
	birth:birth,
	name:name,
	sex:sex,
	location:location,
	introduction:introduction, 
	areaType:areaType,
});
return success;
}
